package inter;

public class TestStu {
    public static void main(String[] args) {
//要求:老师对象升序排序
        Teacher[] teachers =new Teacher[]{
                new Teacher("ton",22),
                new Teacher("kack",20),
                new Teacher("her",30),
                new Teacher("jay",21),
        };
        java.util.Arrays.sort(teachers);//调用工具

        for (int i = 0; i <teachers.length ; i++) {
            System.out.println(teachers[i].name+"\t"+teachers[i].age);
        }
    }
}
class Teacher implements  Comparable<Teacher>{
    String name;
int age;

    public Teacher() {
    }

    public Teacher(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(Teacher o) {
        if(this.age>o.age){
            return  1;
        }else if(this.age<o.age){
            return  -1;
        }
        return 0;
    }
}
